import React from 'react'
// ===================================================================== Temp
import SearchForm from '#cpt/temp/SearchForm'
import Table from '#cpt/temp/Table'
// ===================================================================== global declare
const { $fn, $Lazy } = window
// ===================================================================== $Lazy
const Page 		= $Lazy.load(()=>import('#tp/page/page-container'))
const $time 	= $Lazy.file(()=>import('@com/utils/time'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		pag: {},
		// 搜索表单列表
		forms : [
			{ label: '标本架编号',	name: 'sf_number' },
			{ label: '科室',		name: 'project_name'},
			{ label: '领用时间',		names: ['start_date','end_date'], 	type:'date-range', 	loading:true,	name:'jz-time' },
		],
	}
	model = {}
	
	componentDidMount(){
		$time.then(f=>{
			const arr = f.duration['1-9-9']()
			this.resetModel = { start_date: arr[0], end_date: arr[1], 'jz-time':arr }
			this.model = $fn.copy(this.resetModel)
			if(window.isInit){
				this.fetch()
			}
		})
	}

	// paging
	fetch = () => $fn.fetch.call(this,'shelf/shelfloglist')
	
	// 表单
	cols = [
		{ title: '标本架编号', 	dataIndex: 'sf_number', 		...$fn.table.spec_code },
		{ title: '标本架名称', 	dataIndex: 'sf_name', 			width:150 },
		{ title: '容量', 		dataIndex: 'total_capacity', 	width:100 },
		{ title: '科室', 		dataIndex: 'project_name', 		width:100 },
		{ title: '时间', 		dataIndex: 'created_at',  		...$fn.table.time},
		{ title: '领取人', 		dataIndex: 'real_name',  		...$fn.table.name},
		{ title: '状态', 		dataIndex: 'status_name',  		width:100},
	]
	
	render(){
		return (
			<Page title='领用记录'>
				{/* 搜索 */}
				{ SearchForm.call(this, {timeStr:'1-9-9'}) }
				{/* 表格 */}
				{ Table.call(this, { type: -1, isInit: window.isInit} ) }
			</Page>
		)
	}
}

export default Index